package com.huawei.hwphy2d.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.PaintFlagsDrawFilter;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.huawei.hwphy2d.physical.model.Barrier;
import com.huawei.hwphy2d.physical.model.HwBody;
import java.util.List;

public class HwPhysicalView extends View {
    private boolean isDebug_draw = false;
    private List<HwBody> mActiveList;
    private List<Barrier> mBarriers;

    public HwPhysicalView(@NonNull Context context) {
        super(context);
    }

    public HwPhysicalView(@NonNull Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public void setActiveList(List<HwBody> list) {
        this.mActiveList = list;
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (this.mActiveList != null) {
            canvas.setDrawFilter(new PaintFlagsDrawFilter(0, 3));
            int size = this.mActiveList.size();
            for (int i = 0; i < size; i++) {
                ((HwBody) this.mActiveList.get(i)).draw(canvas);
            }
        }
        if (this.isDebug_draw && !this.mBarriers.isEmpty()) {
            for (Barrier draw : this.mBarriers) {
                draw.draw(canvas);
            }
        }
    }

    public void setDebug_draw(boolean z) {
        this.isDebug_draw = z;
    }

    public void setBarriers(List<Barrier> list) {
        this.mBarriers = list;
    }
}
